-
Notifications
You must be signed in to change notification settings - Fork 0
Add API key authentication middleware for mobile client access #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/api-expansion-mobile-app
Are you sure you want to change the base?
Conversation
Protect /api and /graphql routes with Bearer token auth using timing-safe comparison. Health, metrics, and docs endpoints remain open. Auth is skipped in test environment. API_KEY is required in production via Joi env validation. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@coderabbitai review |
📝 WalkthroughWalkthroughThis change introduces API key-based Bearer token authentication across the application. A new middleware validates incoming requests against an API_KEY environment variable using constant-time comparison, applied conditionally to REST and GraphQL routes when not in test mode. Supporting configuration, comprehensive test coverage, and OpenAPI documentation updates have been added. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Middleware as apiKeyAuth<br/>(Middleware)
participant Config as Environment<br/>(API_KEY)
participant Handler as Route<br/>Handler
Client->>Middleware: Request + Authorization:<br/>Bearer [token]
Middleware->>Config: Read API_KEY
alt API_KEY missing
Middleware->>Client: 500 Server Error
else Authorization header missing
Middleware->>Client: 401 Unauthorized
else Token invalid
Middleware->>Client: 401 Invalid API key
else Token valid (timing-safe compare)
Middleware->>Handler: next()
Handler->>Client: 200 Response
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Actions performedReview triggered.
|
Protect /api and /graphql routes with Bearer token auth using timing-safe comparison. Health, metrics, and docs endpoints remain open. Auth is skipped in test environment. API_KEY is required in production via Joi env validation.
Summary by CodeRabbit
New Features
Tests
Chores